<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/6/16
 * Time: 15:12
 */

namespace common\commands;


use common\models\CommonFunction;
use common\models\Http;
use yii\web\Controller;
use yii\web\HttpException;

class FormController extends Controller{
    public  $layout = false;
    public $enableCsrfValidation = false;

    public function beforeAction($action){
        $action_name = $action->id;
        if($action->id == 'index'){
            Http::cookie('crsf', CommonFunction::encrypt($action_name));
        }
        else{
            $crsf = CommonFunction::decrypt(Http::cookie('crsf'));
            if($crsf != $action_name)
                throw new HttpException(404,'此页面不存在');
        }
        return true;
    }
}